<template>
    <div>
        <div class="line">
            <label class="title">Title:</label><input class="content" v-model="title"/>
        </div>
        <div class="line">
            <label class="title">Content:</label><textarea class="content" v-model="content"></textarea>
        </div>
        <div class="line">
            <button @click="save">Save</button>
        </div>
    </div>
</template>
<script>
import axios from "axios";
export default {
    data(){
        return {
            title:"",
            content:""
        }
    },
    methods:{
        save(){
            if(this.title){
                axios.post('/api/file/add',{
                    title: this.title,
                    content: this.content
                }).then(res=>{
                    if(res.status=='200'){
                        alert('Success save')
                    }else{
                        alert('System error')
                    }
                })
            }else{
                alert('title must input')
            }
        }
    }
}
</script>
<style scoped>
.line{margin-bottom:10px;}
.title{width: 10vw;vertical-align: top;}
.content{width: 30vw;}
textarea{height: 20vh}
</style>